package cn.cxion.chat.app.Fragment;

import android.os.Bundle;
import android.text.Editable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.blankj.utilcode.util.ToastUtils;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnTextChanged;
import cn.cxion.chat.R;
import cn.cxion.chat.app.adapter.OnHandAdapter;
import cn.cxion.chat.app.adapter.WorkAdapter;
import cn.cxion.chat.app.bean.OnHandInfo;


public class WorkFragment extends Fragment {
    @Bind(R.id.et_search)
    EditText etSearch;
    @Bind(R.id.recyclerview)
    RecyclerView recyclerview;
    WorkAdapter adapter;
    private List<OnHandInfo> list;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.main_fragment_work, container, false);
        ButterKnife.bind(this, view);
        init();
        return view;
    }
    @OnTextChanged(value = R.id.et_search, callback = OnTextChanged.Callback.AFTER_TEXT_CHANGED)
    void search(Editable editable) {
        ToastUtils.showShort("搜索"+editable.toString());
    }

    private void init() {
        list=new ArrayList<>();
        for (int i=1;i<3;i++){
            OnHandInfo onHandInfo=new OnHandInfo();
            onHandInfo.setType(0);
            onHandInfo.setT1("法律顾问小组"+i);
            onHandInfo.setT2("下午 1:10");
            onHandInfo.setT3("[主题] 海翼投资");
            list.add(onHandInfo);
        }
        adapter=new WorkAdapter(getActivity());
        adapter.setList(list);
        recyclerview.setLayoutManager(new LinearLayoutManager(getActivity()));
        recyclerview.setAdapter(adapter);

    }
}
